package com.breaktian.demoapp.ui.base;

import android.arch.lifecycle.ViewModel;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.breaktian.assemble.adapter.PermissionAdapter;
import com.breaktian.demoapp.R;
import com.breaktian.demoapp.provider.BaseProvider;
import com.breaktian.demoapp.toobar.ToolBarBuilder;

/**
 * Created by tiankeke on 2017/5/25.
 */

public abstract class Base2Activity<VM extends ViewModel> extends AppCompatActivity {

    //子类可直接使用
    protected PermissionAdapter mPermissionAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPermissionAdapter = new PermissionAdapter(this);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        mPermissionAdapter.onRequestPermissionsResult(requestCode,permissions,grantResults);
    }

    protected void showToolbar(String title){
        new ToolBarBuilder().setToolbar((Toolbar)findViewById(R.id.toolBar)).setTitle(title).hideBackIcon(false)
                .build(this);
    }

    protected abstract VM getViewModel();

}
